#include "widget.h"
#include "ui_widget.h"
#include <QLineEdit>
#include <QPushButton>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{

    ui->setupUi(this);
    this->move(0,0);
    QLineEdit* edit = new QLineEdit(this);
    edit->setText("hello qt!");
    QPushButton * button = new QPushButton(this);
    button->setText("点击关闭页面");
    button->move(0,300);

   // connect(ui->pushButton,&QPushButton::clicked,this,&Widget::handleClick);
    //connect(ui->pushButton,&QPushButton::clicked,button,&QPushButton::click);  //点击ui->pushButton，让button也自己被点击一次

    connect(ui->pushButton,&QPushButton::clicked,button,&QPushButton::setEnabled);//点击ui->pushButton，让button被禁用

}

Widget::~Widget()
{
    delete ui;
}

int Widget::i = 1;

void Widget::handleClick()
{
    /*
    if(ui->pushButton->text()==QString("请点击按钮"))
    {
         ui->pushButton->setText("已点击按钮");
    }
    else
    {
         ui->pushButton->setText("请点击按钮");
    }
    */

    QString str = "已点击次数"+QString::number(Widget::i);
    ui->pushButton->setText(str);
    Widget::i++;

}

